#ifndef __SDK_IFS_UDK_CFG_H__
#define __SDK_IFS_UDK_CFG_H__

#include "sdk_core/rom_def.h"
#include "sys_radar_def.h"
#include "romv30_cstd_lib.h"


/* ---------------------------------------------------------------------------------
udk_cfg 用户区,可修改值,但不要更改格式等(防止gene_bin.exe解析本文件异常)*/

/*是否有opt_data.bin*/
#define OPT_DATA (0)
/*opt_app.bin个数(0~7)：e.g. 2: opt_app1.bin、opt_app2.bin @OPT_APP dir*/
#define OPT_APP  (0)
/*rom or xip starup 0-ROM mode 1-XIP mode */
#define APPLICATION_MODE (0)
/*1:udk-se 2:udk-lite*/
#define UDK_MODE_SETS (2)
/*ota size set必须为16进制格式,必须为4K整数倍*/
#define OTA_SIZE_MAX (0x8000)

/* --------------------------------------------------------------------------------
udk_cfg 系统区 不可修改*/

#if SDK_VERSION == SDK_VERSION_GENE(3,0)

#else
#error "sdk unmatched" // sdk版本未适配
#endif

#define UDK_ASSERT(x) if( !(x) ){udsf_uart_send_string("\nassert failed:"); udsf_uart_send_string(#x);while(1);}

#define APPLICATION_MODE_ROM_START (0)
#define APPLICATION_MODE_XIP_START (1)

#define UDK_VERSION_SE   (1)
#define UDK_VERSION_LITE (2)

#define UDK_VERSION                 (0x3000) // 3.00.0
#define UDK_VERSION_APPEND          "24080118"

#define UDK_SE_UDP_START_ADDR       (SYSBOOT_APP_BASE_INNER)
#define UDK_SE_UDF_START_ADDR       (UDK_SE_UDP_START_ADDR + APP_HEAD_SIZE)

#define UDK_LITE_UDP_START_ADDR     (SYSBOOT_APP_BASE_OUTER)
#define UDK_LITE_UDF_START_ADDR     (UDK_LITE_UDP_START_ADDR + APP_HEAD_SIZE)

#define IIC_Para_ADDR               (1024*120)
#define PIN_Para_ADDR               (1024*100)

#if UDK_MODE_SETS == 1
#define UDF_START_ADDR (UDK_SE_UDF_START_ADDR)
#define UDP_START_ADDR (UDK_SE_UDP_START_ADDR)
#elif UDK_MODE_SETS == 2
#define UDF_START_ADDR (UDK_LITE_UDF_START_ADDR)
#define UDP_START_ADDR (UDK_LITE_UDP_START_ADDR)
#else 
#error xxx
#endif

#if ( SDK_VERSION >= SDK_VERSION_GENE(3,0) )
#if ( SDK_VERSION == SDK_VERSION_GENE(3,0) )
#else
#error "Adaptation required"
#endif
#else
#error UDKv3 just support SDKv3
#endif

typedef int (*UDF15_FUNCTION)(void);

#define bbe_regb_str      BBE
#define ana_Venus_st      ANA
#define paramANA_Venus    (&(((param_2k_t*)UDP_ADDR)->paramANA))
#define paramDataPrep     (&(((param_2k_t*)UDP_ADDR)->paramDataPrep))
#define paramALG          (&(((param_2k_t*)UDP_ADDR)->paramALG))
#define paramFunc         (&(((param_2k_t*)UDP_ADDR)->paramFunc))
#define paramRT           (&(((param_2k_t*)UDP_ADDR)->paramRT))

#define p_rom_gb 	      ((const GLOBAL_PARAM*)(CPU_SRAM_START))
#define p_rom_uart_recv   ((struct uart_recv *)(CPU_SRAM_START))
#define p_rom_anychar_reset_dis (uint32_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->startup))
#define p_rom_app_offset  (uint32_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->app_offset))
#define p_rom_user_function  (uint32_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->user_memcpy))
#define p_rom_printen        (uint8_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->printen))

#define p_boot_flag        (uint8_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->boot_flag))
#define p_app_location     (uint8_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->app_location))
#define p_app_offset       (uint8_t*)(&(((GLOBAL_PARAM*)(CPU_SRAM_START))->app_offset))

#if (APPLICATION_MODE == APPLICATION_MODE_ROM_START)

#elif (APPLICATION_MODE == APPLICATION_MODE_XIP_START)

#else
#error UNKNOWN_APPLICATION_MODE
#endif



#define UART_RECV_STRUCT_BASE (0x20000000)

#if defined(API_CFG_PREPDATA_HANDLE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define PREPDATA_HANDLE         udsf_prepdata_handle
#else
#define PREPDATA_HANDLE         SAPI_PREPDATA_HANDLE
#endif

#if defined(API_CFG_ANACFG_SET_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define ANACFG_SET              udsf_anacfg_set
#else
#define ANACFG_SET              SAPI_ANACFG_SET
#endif

#if defined( API_CFG_BBE_PREPINIT_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define BBE_PREPINIT            udsf_bbe_prepinit
#else
#define BBE_PREPINIT            SAPI_BBE_PREPINIT
#endif

#if defined( API_CFG_RF_VENUS_INIT_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define RF_VENUS_INIT           udsf_rf_venus_init
#else
#define RF_VENUS_INIT           SAPI_RF_VENUS_INIT
#endif

#if defined( API_CFG_BBE_WAITISR_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define BBE_WAITISR             udsf_bbe_waitisr
#else
#define BBE_WAITISR             SAPI_BBE_WAITISR
#endif

#if defined( API_CFG_RF_VENUS_DEINIT_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define RF_VENUS_DEINIT         udsf_rf_venus_deinit
#else
#define RF_VENUS_DEINIT         SAPI_RF_VENUS_DEINIT
#endif

#if defined( API_CFG_P2_FFT_STEPCFG8_HANDLE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define P2_FFT_STEPCFG8_HANDLE  udsf_p2_fft_stepcfg8_handle
#else
#define P2_FFT_STEPCFG8_HANDLE  SAPI_P2_FFT_STEPCFG8_HANDLE
#endif

#if defined( API_CFG_P2_FFT_HANDLE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define P2_FFT_HANDLE           udsf_p2_fft_handle
#else
#define P2_FFT_HANDLE           SAPI_P2_FFT_HANDLE
#endif

#if defined( API_CFG_ANGLE_SEQ_PRE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)  
#define ANGLE_SEQ_PRE           udsf_angle_seq_pre
#else
#define ANGLE_SEQ_PRE           SAPI_ANGLE_SEQ_PRE
#endif

#if defined( API_CFG_FFT3D_PRE_HANDLE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START) 
#define FFT3D_PRE_HANDLE        udsf_fft3d_pre_handle
#else
#define FFT3D_PRE_HANDLE        SAPI_FFT3D_PRE_HANDLE
#endif

#if defined( API_CFG_WDT_RSTNOW_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START) 
#define WDT_RSTNOW              udsf_wdt_rstnow
#else
#define WDT_RSTNOW              SAPI_WDT_RSTNOW
#endif

#if defined( API_CFG_CFAR_HANDLE_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define CFAR_HANDLE             udsf_cfar_handle
#else
#define CFAR_HANDLE             SAPI_CFAR_HANDLE
#endif

#if defined( API_CFG_CMPHIT_CFAR_TARGET_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define CMPHIT_CFAR_TARGET      udsf_cmphit_cfar_target
#else
#define CMPHIT_CFAR_TARGET      SAPI_CMPHIT_CFAR_TARGET
#endif


#if defined( API_CFG_DBSCAN_CLUSTER_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define DBSCAN_CLUSTER_PROC     udsf_dbscan_cluster_proc
//#define DBSCAN_CLUSTER_PROC     SAPI_DBSCAN_CLUSTER_PROC
#else
#define DBSCAN_CLUSTER_PROC     SAPI_DBSCAN_CLUSTER_PROC
#endif

#if defined( API_CFG_ALPHA_FILTER_UDSF) && (APPLICATION_MODE == APPLICATION_MODE_XIP_START)
#define ALPHA_FILTER_PROC       udsf_alpha_filter_proc
//#define ALPHA_FILTER_PROC       SAPI_ALPHA_FILTER_PROC
#else
#define ALPHA_FILTER_PROC       SAPI_ALPHA_FILTER_PROC
#endif

#define RADARLIB_GET_VERSION    SAPI_GET_VERSION

#include "sys_api.h"

#endif
